﻿using System;
using Netkk.Common.Models;

namespace Netkk.Models
{
    public class LinkModel
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
        public string Url { get; set; }
        public string Description { get; set; }
        public int Order { get; set; }
        public string Category { get; set; }
        public bool AllowEditOrAdd { get; set; }

        public static LinkModel Create()
        {
            return new LinkModel
                       {
                           Id = Guid.NewGuid(),
                           Name = String.Empty,
                           Url = String.Empty,
                           Description = String.Empty,
                           Order = 0,
                           Category = String.Empty
                       };
        }
        public static LinkModel Create(Link link)
        {
            return new LinkModel
            {
                Id = link.Id,
                Name = link.Name,
                Url = link.Url,
                Description = link.Description,
                Order = link.Order,
                Category = link.Category
            };
        }
        public static LinkModel Create(Link link, bool allowEditOrAdd)
        {
            return new LinkModel
            {
                Id = link.Id,
                Name = link.Name,
                Url = link.Url,
                Description = link.Description,
                Order = link.Order,
                Category = link.Category,
                AllowEditOrAdd = allowEditOrAdd
            };
        }

        public Link MapToLink()
        {
            return new Link
                       {
                           Category = Category,
                           Description = Description,
                           Id = Id,
                           Name = Name,
                           Order = Order,
                           Url = Url
                       };
        }
    }
}
